package lasec.connect;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * 
 * @author Ignatius
 */
public class ConnectionFactoryImpl extends ConnectionFactory {

	private String driver;
	private String url;
	private String username;
	private String password;

	public ConnectionFactoryImpl(String driver, String url, String username,
			String password) {
		this.driver = driver;
		this.url = url;
		this.username = username;
		this.password = password;
	}

	@Override
	public Connection getConnection() {
		try {
			Class.forName(driver);
			Connection conn = DriverManager.getConnection(url, username,
					password);
			return conn;
		} catch (SQLException ex) {
			Logger.getLogger(ConnectionFactoryImpl.class.getName()).log(
					Level.SEVERE, null, ex);
		} catch (ClassNotFoundException ex) {
			Logger.getLogger(ConnectionFactoryImpl.class.getName()).log(
					Level.SEVERE, null, ex);
		}
		return null;
	}

}